package com.lyxmaster.lib.view;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;

/**
 * Created by LYX on 2018/3/23.
 */

public class BaseFragment extends Fragment {
    @Override
     public void onSaveInstanceState(Bundle outState) {
               super.onSaveInstanceState(outState);
    }

    private Activity activity;

    public Context getContext() {
        if (activity == null) {
            return MyApplication.getInstance();
        }
        return activity;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        activity = getActivity();
    }

    public BaseFragment newInstance(String text){
        Bundle bundle = new Bundle();
        bundle.putString("msg", text);
        //fragment保存参数，传入一个Bundle对象
        this.setArguments(bundle);
        return this;
    }
}
